<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>

<!DOCTYPE html>
<html class='no-js' lang='cn'>
  <jsp:include page="/head.jsp"/>
  <body class='main page'>
  <jsp:include page="/top.jsp"/>
  
  <div id='wrapper'>
   	<section id='tools'>
        <ul class='breadcrumb' id='breadcrumb'>
          <li class='title'>JOB列表</li>
          <li class='active'>${_jobType}</li>
        </ul>
        <div id='toolbar'>
          <div class='btn-group'>
            <a class='btn' data-toggle='toolbar-tooltip' href='${ctx }/admin/job/new/${_jobType }' title='Add'>
              <i class='icon-plus'></i>
            </a>
          </div>
        </div>
      </section><!-- Sidebar -->
  <jsp:include page="/sidebar.jsp"/>
    
      <!-- Content -->
      <div id='content'>
          
          <table class='table'>
            <thead>
              <tr>
                <th>名称</th>
                <th>线程数</th>
                <th>采集规则</th>
                <th>采集深度</th>
                <th>保存html</th>
                <th>用户</th>
                <th>创建时间</th>
                <th>修改时间</th>
                <th>状态</th>
                <th class="text-right">操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="record" items="${obj.rows }" varStatus="status">
              <tr class='${ status.index%2==0?'success':''}' id="row_${record.name }">
                <td>${record.name }</td>
                <td>${record.threadNum }</td>
                <td>${record.rule }</td>
                <td>${record.depth }</td>
                <td>${record.saveHtml?'保存':'不保存' }</td>
                <td>${record.user }</td>
                <td> <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${record.createTime }" /></td>
                <td> <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${record.updateTime }" /></td>
                <td>${record.statusStr }</td>
                <td class='text-right'>
                  <a class='btn btn-success' data-toggle='tooltip' href='${ctx }/admin/job/show/${record.name}' title='查看'>
                    <i class='icon-zoom-in'></i>
                  </a>
                  <a class='btn btn-info' href='${ctx }/admin/job/get/${record.name}'>
                    <i class='icon-edit'></i>
                  </a>
		           <a class='btn btn-danger' href='#' onclick="deleteJob('${record.name }')">
                    <i class='icon-trash'></i>
                  </a>
                </td>
              </tr>
              </c:forEach>
            </tbody>
          </table>
          <div class='panel-footer'>
            <ul class='pagination pagination-sm '>
              <li>
                <a href='#'>«</a>
              </li>
              <li class='active'>
                <a href='#'>1</a>
              </li>
              <li>
                <a href='#'>2</a>
              </li>
              <li>
                <a href='#'>3</a>
              </li>
              <li>
                <a href='#'>4</a>
              </li>
              <li>
                <a href='#'>5</a>
              </li>
              <li>
                <a href='#'>6</a>
              </li>
              <li>
                <a href='#'>7</a>
              </li>
              <li>
                <a href='#'>8</a>
              </li>
              <li>
                <a href='#'>»</a>
              </li>
            </ul>
          </div>
        </div>
       </div>
    <jsp:include page="/foot.jsp"/>
    
    <script type="text/javascript">
    	function deleteJob(jobName){
    		bootbox.confirm("是否确定删除job:"+jobName, function (result) {  
                if(result) {  
                	  $.get('${ctx}/admin/job/drop/'+jobName, function(result){
                			 if(result.ok){
              					$("#row_"+jobName).hide() ;
              				}else{
              					bootbox.alert("删除失败:"+result.message);
              				}
              				
              			}, "json").error(function(result) {
              				bootbox.alert("删除失败,无响应!");
              			});
                }
            }); 
    	}
    </script>
  </body>
</html>
